
package com.zxg.util.concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class FutureTaskPool<T> {

  ExecutorService exec;

  public FutureTaskPool(int num) {
    exec = Executors.newFixedThreadPool(num);
  }

  public FutureTask<T> submit(Callable<T> t) {
    FutureTask<T> futureTask = new FutureTask<T>(t);
    exec.submit(futureTask);
    return futureTask;
  }

  public void shutdown() {
    this.exec.shutdown();
  }

  public ExecutorService getExec() {
    return exec;
  }

  public void setExec(ExecutorService exec) {
    this.exec = exec;
  }

}
